import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 圣言术-怒
 **/
export default class MS_HolyFury extends AbilityBase {
    static instance: MS_HolyFury;
    buffType: AppBuffType = {
        id: 'buff_MS_HolyFury',
        art: this.art,
        name: this.abilityName,
        ubertip: '增加攻击与法强',
        dur: 20,
        stackCountMax: 3,
        attribute: {},
        targetArt: 'Abilities\\Spells\\Other\\GeneralAuraTarget\\GeneralAuraTarget.mdl',
        targetAttach: 'foot',
    };
    debuffType: AppBuffType = {
        id: 'buff_MS_HolyFury_debuff',
        art: this.art,
        name: this.abilityName,
        ubertip: '降低攻击与法强',
        dur: 20,
        stackCountMax: 6,
        targetArt: 'Abilities\\Spells\\Other\\GeneralAuraTarget\\GeneralAuraTarget.mdl',
        targetAttach: 'foot',
        attribute: {},
        isDebuff: true,
    };
    constructor(id: string) {
        super(id);
        MS_HolyFury.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
        BuffUtil.registerBuffType(this.debuffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let ally = IsUnitAlly(target, GetOwningPlayer(source));
        let lv = this.getAbilityLevel(source);
        let val = (7 + UnitCommon.getFullProperty(source) / 20) * lv;
        let dmg = 14 * lv + UnitCommon.取法强(source) * (0.3 + 0.2 * lv);
        if (ally) {
            DamageSystemInstance.applyHeal(target, source, dmg, this.id);
        } else {
            DamageSystemInstance.applyLightDamage(target, source, dmg, this.id);
            val *= -1;
        }
        BuffCommon.addBuff({
            target,
            caster: source,
            buffTypeId: this.buffType.id,
            ablityId: this.id,
            attribute: {
                attack: val,
                法术强度: val,
            },
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
